<?php
class tpolice extends CI_Model{
	var $datapolice = "t_data_police";

	function __construct()
	{
		parent::__construct();
	}
	
	function setData($id_police,$no_agenda,$no_seri,$no_kwitansi,$tgl_terbit_police,$tgl_akhir_berlaku,$keperluan,$sidik_jari_atas,$sidik_jari_bawah,$op_catatan,$pasal,$undang_undang,$nomor_bulan,$nomor_tahun,$nomor_sat,$id_sektor,$ttd_perwakilan,$id_pengaju,$is_pengajuan)
	{
		$this->id_police= $id_police;
		$this->no_agenda= $no_agenda;
		$this->no_seri= $no_seri;
		$this->no_kwitansi= $no_kwitansi;
		$this->tgl_terbit_police= $tgl_terbit_police;
		$this->tgl_akhir_berlaku= $tgl_akhir_berlaku;
		$this->keperluan= $keperluan;
		$this->sidik_jari_atas= $sidik_jari_atas;
		$this->sidik_jari_bawah= $sidik_jari_bawah;
		$this->op_catatan= $op_catatan;
		$this->pasal= $pasal;
		$this->undang_undang= $undang_undang;
		$this->nomor_bulan= $nomor_bulan;
		$this->nomor_tahun= $nomor_tahun;
		$this->nomor_sat= $nomor_sat;
		$this->id_sektor= $id_sektor;
		$this->ttd_perwakilan= $ttd_perwakilan;
		$this->id_pengaju= $id_pengaju;
		$this->is_pengajuan= $is_pengajuan;
	}
	
	function getList(){
		$query = $this->db->get($this->datapolice);
		if($query->num_rows() > 0){
			foreach($query->result_array() as $row){
				$result[] = $row;
			}
			return $result;
		} else {
			return false;
		}	
	}
	
	function create()
	{		
		$arrayData = array(
			'id_police'=>$this->id_police,
			'no_agenda'=>$this->no_agenda,
			'no_seri'=>$this->no_seri,
			'no_kwitansi'=>$this->no_kwitansi,
			'tgl_terbit_police'=>$this->tgl_terbit_police,
			'tgl_akhir_berlaku'=>$this->tgl_akhir_berlaku,
			'keperluan'=>$this->keperluan,
			'sidik_jari_atas'=>$this->sidik_jari_atas,
			'sidik_jari_bawah'=>$this->sidik_jari_bawah,
			'op_catatan'=>$this->op_catatan,
			'pasal'=>$this->pasal,
			'undang_undang'=>$this->undang_undang,
			'nomor_bulan'=>$this->nomor_bulan,
			'nomor_tahun'=>$this->nomor_tahun,
			'nomor_sat'=>$this->nomor_sat,
			'id_sektor'=>$this->id_sektor,
			'ttd_perwakilan'=>$this->ttd_perwakilan,
			'id_pengaju'=>$this->id_pengaju,
			'is_pengajuan'=>$this->is_pengajuan
		);
		return $this->db->insert($this->datapolice, $arrayData);
	}
	
	function update($id_pengaju)
	{
		$arrayData = array(
			'id_police'=>$this->id_police,
			'no_agenda'=>$this->no_agenda,
			'no_seri'=>$this->no_seri,
			'no_kwitansi'=>$this->no_kwitansi,
			'tgl_terbit_police'=>$this->tgl_terbit_police,
			'tgl_akhir_berlaku'=>$this->tgl_akhir_berlaku,
			'keperluan'=>$this->keperluan,
			'sidik_jari_atas'=>$this->sidik_jari_atas,
			'sidik_jari_bawah'=>$this->sidik_jari_bawah,
			'op_catatan'=>$this->op_catatan,
			'pasal'=>$this->pasal,
			'undang_undang'=>$this->undang_undang,
			'nomor_bulan'=>$this->nomor_bulan,
			'nomor_tahun'=>$this->nomor_tahun,
			'nomor_sat'=>$this->nomor_sat,
			'id_sektor'=>$this->id_sektor,
			'ttd_perwakilan'=>$this->ttd_perwakilan,
			'is_pengajuan'=>$this->is_pengajuan
		);
		$this->db->where('id_pengaju', $id_pengaju);
		return $this->db->update($this->datapolice, $arrayData);
	}
        
	function remove($id_pengaju)
	{
		$this->db->where('id_pengaju', $id_pengaju);
		return $this->db->delete($this->datapolice);
	}	
	
	function detail($id_pengaju)
	{
		$this->db->where('id_pengaju', $id_pengaju);
		$query = $this->db->get($this->datapolice);	
		return $query->result_array();
	}
}
?>